import { defineStore } from "pinia";
import { Ref, ref } from "vue";

interface settingInterface {
  isCollapse: Ref<boolean>;
  refresh: Ref<boolean>;
  changeCollapse: () => void;
  changeRefresh: (flag: boolean) => void;
}

const useSetting = defineStore("setting", (): settingInterface => {

  /* 是否展开或者收起侧边栏组件 */
  const isCollapse: Ref<boolean> = ref<boolean>(false);
  /* 刷新的状态 */
  const refresh: Ref<boolean> = ref<boolean>(false);
  /* 用于展开或者收起侧边栏组件的回调函数 */
  const changeCollapse: () => void = (): void => {
    isCollapse.value = !isCollapse.value;
  };
  /* 用于修改刷新状态的回调函数 */
  const changeRefresh: (flag: boolean) => void = (flag: boolean): void => {
    refresh.value = flag;
  };

  return {
    isCollapse,
    changeCollapse,
    refresh,
    changeRefresh,
  };

});

export default useSetting;
